var app = getApp()
let api = require('../../../api/api.js')
var util = require("../../../utils/util.js")
Page({
  data: {
    currentTab: 0,
    currentTab_1: 0
  },

  // 累积收益查看明细
  detail: function (e) {
    var mobile = app.globalData.userInerInfo.number
    var id = app.globalData.userInerInfo.id
    var index = e.currentTarget.dataset.index
    wx.navigateTo({
      url: '/pages/A/detail/detail?mobile=' + mobile + "&id=" + id + "&level=2&index=" + index,
    })
  },

  onLoad: function (options) {
    console.log(options)
    const scene = decodeURIComponent(options.scene)
    // 页面初始化 options为页面跳转所带来的参数
    // console.log(app.globalData.userInerInfo)
    var that = this
    var data = {
      mobile: app.globalData.userInerInfo.number,
      type: 2
    }
      api.pagebottom(data, res => {
        console.log(res)
        that.setData({
          content: res.data.result.click
        })
      })

  },
  onShow: function () {
    console.log(app.globalData.userInerInfo)
    this.setData({
      userInfo: app.globalData.userInerInfo
    })
  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    that.setData({
      currentTab_1: e.detail.current
    });
  },
  user: function (e) {
    console.log(app.globalData.userInerInfo)
    var mobile = app.globalData.userInerInfo.number
    var id = app.globalData.userInerInfo.id
    wx.navigateTo({
      url: '/pages/A/user_order/user_order?mobile=' + mobile + "&id=" + id + "&type=2" + "&level=2",
    })
  },

  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab_1: e.target.dataset.current
      })
    }
  },
  clickTab_1: function (e) {
    var that = this;
    if (this.data.currentTab_1 === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab_1: e.target.dataset.current
      })
    }
  },
  // 点击头像
  message: function (e) {
    console.log(e)
    var mobile = app.globalData.userInerInfo.number
    console.log(mobile)
    wx.navigateTo({
      url: '/pages/A/message/message?mobile=' + mobile,
    })
  },
  onPullDownRefresh() {
    var that = this
    var phone = util.getInfoFromStorage("mobile")
    var code = util.getInfoFromStorage("verify")
    if (phone != "") {
      //登陆获取验证码传type=1
      util.sendRequest("/api/dblong/index", { mobile: phone, verify: code, type: 1 }, "POST", false, function (res) {
        console.log(res)
        app.globalData.userInerInfo = res.result
        that.onShow()
        wx.stopPullDownRefresh()
        
      })
    }
  },
})